<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="__ROOT__/Public/Js/jquery-1.5.0.min.js"></script>
    <script type="text/javascript" src="__ROOT__/Public/Js/core.js"></script>
    <script type="text/javascript" src="__ROOT__/Public/Js/WdatePicker.js"></script>
    <title>EHS中国供求后台管理系统</title>
  </head>
  <body>
    <div id="container">
      <layout name="requireAdmin:left" cache="0"/>
      <div id="main">
        <div id="condition">
          <form id="frmCondition" action="/main/admin.php/requireAdmin/index/" method="get">
            搜索条件<br/>
            发布时间从 <input name="from" class="Wdate" type="text" size="14" maxlength="10" onClick="WdatePicker()" value="{$from}"/>
            到 <input name="to" class="Wdate" type="text" size="14" maxlength="10" onClick="WdatePicker()" value="{$to}"/>
            信息类别:
            <select id="selType" name="type" style="width:150px" onchange="changeType(this)">
              <option value="0">全部</option>
              <option value="1">活动</option>
              <option value="3">培训</option>
              <option value="5">招聘求职</option>
              <option value="7">EHS需求</option>
            </select>
            <select id="selSub" name="sub" style="width:120px">
              <option value="0">全部</option>
            </select> 
            <br/>
            <!--地区:
            <select name="fdq_id" onchange="changeRegion(this)" style="width:150px">
              <option value="0">全部</option>
              <volist name="region" id="vo">
                <option value="{$vo.id}">{$vo.title}</option>
              </volist>
            </select>
            <select name="dq_id">
              <option value="0">全部</option>
            </select> -->
            标题：<input name="title" type="text" style="width:300px" value="{$title}"/>
            <input type="submit" value="查找"/>
          </form>
        </div>

        <form id="frmList" action="__URL__/operateSubmit/" method="post">
          <table border="1">
            <tr><td></td><td>序号</td><td>类型</td><td>子类型</td><td>标题</td><td>状态</td><td>发表人</td><td>发表时间</td></tr>
            <volist name="list" id="vo">
              <tr><td><input type="checkbox" name="ids[]" value="{$vo.id}"/></td>
                <td>{$i}</td><td>{$types[$vo[type]][name]}</td><td>{$types[$vo[type]][sub][$vo[sub]]}</td>
                <td><if condition="$vo.status eq 0"><span style="color: red;font-size: 12px">[未审核]</span></if>
                  <a href="/main/public.php/require/content/id/{$vo.id}" target="_blank">{$vo.title}</a>
                  <if condition="$vo.top eq 1"><span style="color: red;font-size: 12px">[置顶]</span></if>
                </td>
                <td>
                  <if condition="$vo.status eq 0"><span style="color:red">未审核</span><elseif condition="$vo.status eq 1"/>审核通过<else/>审核不通过</if>
                </td>
                <td>{$vo.username}</td><td>{$vo.pub_time}</td>
              </tr>
            </volist>
          </table>
          <div>{$page}</div>
          <input type="hidden" name="type" id="hiddenType" value=""/>
          <input type="button" value="全选" onclick="changeCheckBox(1)"/>
          <input type="button" value="不选" onclick="changeCheckBox(2)"/>
          <input type="button" value="反选" onclick="changeCheckBox(3)"/>
          <input type="button" value="置顶" onclick="operate(1)"/>
          <input type="button" value="取消置顶" onclick="operate(2)"/>
          <input type="button" value="审核通过" onclick="operate(3)"/>
          <input type="button" value="审核不通过" onclick="operate(4)"/>
          <input type="button" value="删除" onclick="operate(5)"/>
        </form>

      </div>
    </div>
    <script>
      var url = '__URL__';
      //初始化一些查询条件
      var type = "{$type}" == ''?0:"{$type}";
      var sub = "{$sub}" == ''?0:"{$sub}";
      $("#selType").val(type);
      changeType("#selType");
      $("#selSub").val(sub);
      //改变类型下拉框
      function changeType(self){
        var type = $(self).val();
        var strs = {
          0: '<option value=0>全部</option>',
          1: '<option value=0>全部</option><option value=1>会务</option><option value=2>聚会</option>',
          3: '<option value=0>全部</option>',
          5: '<option value=0>全部</option><option value=1>招聘</option><option value=2>求职</option>',
          7: '<option value=0>全部</option><option value=1>产品</option><option value=2>EHS服务</option><option value=3>工程</option><option value=4>悬赏或招标</option>'
        };
        var hidden = type == 3 ? '.hide()' : '.show()';
        eval('$(self).next("select").html("'+strs[type]+'")'+hidden);
      }

      //改变地区下拉框
      function changeRegion(self){
        var id = $(self).val();
        var data = {id:id};
        ajax.send(url+'/ajaxChgRegion',data,function(obj){
          var data = obj.data;
          $(self).next('select').html(_getHTMLRegion(data));
        });
      }
      //画二级地区的select
      function _getHTMLRegion(list){
        var str = [], p = 0;
        str[p++] = '<option value=0>全部</option>';
        for (var i in list){
          var l = list[i];
          str[p++] = '<option value="'+l.id+'">'+l.title+'</option>';
        }
        return str.join('');
      }
      //全选，不选，反选三个功能
      function changeCheckBox(type){
        $("#frmList input[type=checkbox]").each(function(i,self){
          if (type == 1) $(self).attr('checked',true);
          else if (type == 2) $(self).attr('checked',false);
          else if (type == 3) {
            $(self).attr('checked')?$(self).attr('checked',false):$(self).attr('checked',true);
          }
        });
      }
      //置顶，取消置顶，审核通过，审核不通过，删除五个功能
      function operate(type){
        $("#hiddenType").val(type);
        var count = 0;
        $('#frmList input[type=checkbox]').each(function(){
          $(this).attr('checked') && count++;
        });
        if (count == 0) {
          alert("请选择记录");
          return ;
        }else $('#frmList').submit();
      }
    </script>
  </body>
</html>
